package com.swgk.core.recyclerview.decoration;

import android.graphics.Rect;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

/**
 * XRecyclerView 专用网格分割:
 * Author Andy
 * Time 2020/06/25
 */
public class RecyclerViewItemDecoration2 extends RecyclerView.ItemDecoration {
    private float space = 0;
    private float spaceMid = 0;

    public RecyclerViewItemDecoration2(float space, float spaceMid) {
        this.space = space;
        this.spaceMid = spaceMid;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        outRect.bottom = (int) space;
        if (parent.getChildLayoutPosition(view) % 2 == 0) {
            outRect.right = (int) space;
            outRect.left = (int) spaceMid / 2;
        } else {
            outRect.left = (int) space;
            outRect.right = (int) spaceMid / 2;
        }

    }
}
